From: Keir Fraser Date: Fri, 5 Sep 2008 10:56:35 +0000 (+0100) Subject: lsevtchn: Improve this evtchn reporting tool. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14111^2~38 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=406b8494bb6b72abd13da118da1f4c82433e4de8;p=xen.git lsevtchn: Improve this evtchn reporting tool. Signed-off-by: Keir Fraser --- diff --git a/tools/libxc/xc_evtchn.c b/tools/libxc/xc_evtchn.c index 5e1ca26502..204698abe0 100644 --- a/tools/libxc/xc_evtchn.c +++ b/tools/libxc/xc_evtchn.c @@ -59,17 +59,8 @@ int xc_evtchn_reset(int xc_handle, return do_evtchn_op(xc_handle, EVTCHNOP_reset, &arg, sizeof(arg), 0); } -int xc_evtchn_status(int xc_handle, - uint32_t dom, - uint32_t port) +int xc_evtchn_status(int xc_handle, xc_evtchn_status_t *status) { - int rc; - struct evtchn_status arg = { .dom = (domid_t)dom, - .port = (evtchn_port_t)port }; - - rc = do_evtchn_op(xc_handle, EVTCHNOP_status, &arg, sizeof(arg), 1); - if ( rc == 0 ) - rc = arg.status; - - return rc; + return do_evtchn_op(xc_handle, EVTCHNOP_status, status, + sizeof(*status), 1); } diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 8b4ed304e5..7202e8171d 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -502,9 +502,9 @@ xc_evtchn_alloc_unbound(int xc_handle, int xc_evtchn_reset(int xc_handle, uint32_t dom); -int xc_evtchn_status(int xc_handle, - uint32_t dom, - uint32_t port); + +typedef struct evtchn_status xc_evtchn_status_t; +int xc_evtchn_status(int xc_handle, xc_evtchn_status_t *status); /* * Return a handle to the event channel driver, or -1 on failure, in which case diff --git a/tools/xcutils/lsevtchn.c b/tools/xcutils/lsevtchn.c index 3dc3cb3c42..7e7bcbeff7 100644 --- a/tools/xcutils/lsevtchn.c +++ b/tools/xcutils/lsevtchn.c @@ -8,49 +8,55 @@ #include #include -int -main(int argc, char **argv) +int main(int argc, char **argv) { - int xc_fd; - int domid = 0, port = 0, status; - const char *msg; + int xc_fd, domid, port, rc; + xc_evtchn_status_t status; - if ( argc > 1 ) - domid = strtol(argv[1], NULL, 10); + domid = (argc > 1) ? strtol(argv[1], NULL, 10) : 0; xc_fd = xc_interface_open(); if ( xc_fd < 0 ) errx(1, "failed to open control interface"); - while ( (status = xc_evtchn_status(xc_fd, domid, port)) >= 0 ) + for ( port = 0; ; port++ ) { - switch ( status ) - { - case EVTCHNSTAT_closed: - msg = "Channel is not in use."; + status.dom = domid; + status.port = port; + rc = xc_evtchn_status(xc_fd, &status); + if ( rc < 0 ) break; + + if ( status.status == EVTCHNSTAT_closed ) + continue; + + printf("%4d: VCPU %u: ", port, status.vcpu); + + switch ( status.status ) + { case EVTCHNSTAT_unbound: - msg = "Channel is waiting interdom connection."; + printf("Interdomain (Waiting connection) - Remote Domain %u", + status.u.unbound.dom); break; case EVTCHNSTAT_interdomain: - msg = "Channel is connected to remote domain."; + printf("Interdomain (Connected) - Remote Domain %u, Port %u", + status.u.interdomain.dom, status.u.interdomain.port); break; case EVTCHNSTAT_pirq: - msg = "Channel is bound to a phys IRQ line."; + printf("Physical IRQ %u", status.u.pirq); break; case EVTCHNSTAT_virq: - msg = "Channel is bound to a virtual IRQ line."; + printf("Virtual IRQ %u", status.u.virq); break; case EVTCHNSTAT_ipi: - msg = "Channel is bound to a virtual IPI line."; + printf("IPI"); break; default: - msg = "Unknown."; + printf("Unknown"); break; - } - printf("%03d: %d: %s\n", port, status, msg); - port++; + + printf("\n"); } xc_interface_close(xc_fd);